package com.ycy.variable;

import com.ycy.BaseTest;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.junit.Test;

import java.util.List;
import java.util.Map;

public class HistoricTaskQuery extends BaseTest {

  @Test
  public void query1() {
    List<HistoricTaskInstance> list
            = processEngine.getHistoryService().createHistoricTaskInstanceQuery().processInstanceId("2504")
            .includeProcessVariables().includeTaskLocalVariables().
                    list();
    /**
     * 查询历史任务 （完成和未完成的）
     */
    for (HistoricTaskInstance historicTaskInstance : list) {

      Map<String, Object> processVariables = historicTaskInstance.getProcessVariables();
      System.out.println(historicTaskInstance + " " + processVariables);

      Map<String, Object> taskLocalVariables = historicTaskInstance.getTaskLocalVariables();
      System.out.println(historicTaskInstance + " " + taskLocalVariables);


//      String taskId = historicTaskInstance.getId();
//      //获得流程变量
//      Map<String, Object> map = taskService.getVariables(taskId);
//      //获得局部变量
//      Map<String, Object> localMap = taskService.getVariablesLocal(taskId);
//
//      historyService.createHistoricVariableInstanceQuery()
//
//      System.out.println(map);
//      System.out.println(localMap);
      System.out.println("===============");

    }

  }

}
